<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:zj="http://www.zju.edu.cn" exclude-result-prefixes="zj">
  <xsl:template name="zj:SortColHead">
    <xsl:param name="Title"/>
    <th nowrap="">
      <xsl:if test="zj:Display/@ListWidth">
        <xsl:attribute name="width">
          <xsl:value-of select="zj:Display/@ListWidth"/>
        </xsl:attribute>
      </xsl:if>
      <a style="text-decoration:none" href="{concat($zj:ListHeadUrl, '&amp;Page=', $zj:CurPage, '&amp;Sort=', position(), '&amp;Order=', $zj:Sort/Order)}">
        <xsl:value-of select="$Title"/>
        <xsl:call-template name="zj:WhiteSpace"/>
        <xsl:choose>
          <xsl:when test="$zj:Sort/Order='DESC'">
            <IMG align="absmiddle" alt="升序" border="0" height="8" src="../images2/rank_up.gif" width="7"/>
          </xsl:when>
          <xsl:when test="$zj:Sort/Order='ASC'">
            <IMG align="absmiddle" alt="降序" border="0" height="8" src="../images2/rank_down.gif" width="7"/>
          </xsl:when>
        </xsl:choose>
      </a>
    </th>
  </xsl:template>
  <xsl:template match="Page">
    <table cellspacing="0" cellpadding="2" border="0" width="100%">
      <tr>
        <td nowrap="">
          <a title="首页">
            <xsl:if test="$zj:CurPage>1">
              <xsl:attribute name="href">
                <xsl:value-of select="concat($zj:ListHeadUrl, '&amp;Page=1', $zj:ListOrder)"/>
              </xsl:attribute>
            </xsl:if>
            <font face="webdings">9</font>
          </a>
          <xsl:call-template name="zj:WhiteSpace"/>
          <a title="前十页">
            <xsl:if test="$zj:CurPage>10">
              <xsl:attribute name="href">
                <xsl:value-of select="concat($zj:ListHeadUrl, '&amp;Page=', $zj:CurPage - 10, $zj:ListOrder)"/>
              </xsl:attribute>
            </xsl:if>
            <font face="webdings">7</font>
          </a>
          <xsl:call-template name="zj:WhiteSpace"/>
          <xsl:apply-templates select="$zj:Toolkit/NewPage"/>
          <a title="后十页">
            <xsl:if test="($zj:CurPage &lt;= TotalPage - 10)">
              <xsl:attribute name="href">
                <xsl:value-of select="concat($zj:ListHeadUrl, '&amp;Page=', $zj:CurPage + 10, $zj:ListOrder)"/>
              </xsl:attribute>
            </xsl:if>
            <font face="webdings">8</font>
          </a>
          <xsl:call-template name="zj:WhiteSpace"/>
          <a title="末页">
            <xsl:if test="$zj:CurPage &lt; TotalPage">
              <xsl:attribute name="href">
                <xsl:value-of select="concat($zj:ListHeadUrl, '&amp;Page=', TotalPage, $zj:ListOrder)"/>
              </xsl:attribute>
            </xsl:if>
            <font face="webdings">:</font>
          </a>
          <xsl:call-template name="zj:WhiteSpace"/>共<font color="red">
            <b>
              <xsl:value-of select="TotalPage"/>
            </b>
          </font>页
          <font color="red">
            <b>
              <xsl:value-of select="TotalRows"/>
            </b>
          </font>条记录
          <input id="MyPageID" name="MyPageID" type="text" size="3" value="{$zj:CurPage}"/>
          <a href="#" class="l-btn l-btn-plain"  onclick="changePage()" >
            <span class="l-btn-left">
              <span class="l-btn-text icon-reload" style="padding-left: 20px; ">Go</span>
            </span>
          </a>
        </td>
        <td align="right" nowrap="">
          <xsl:apply-templates select="$zj:XmlData/Toolkit/@Module" mode="zj:Button"/>
        </td>
      </tr>
    </table>
  </xsl:template>
  <xsl:template match="@Module[.='AllRow2']" mode="zj:Button">
    <table border="0">
      <tr>
        <td valign="top">
          <xsl:call-template name="zj:ExcelButton"/>
          <xsl:call-template name="zj:HRefButton">
            <xsl:with-param name="Name" select="'修改'"/>
            <xsl:with-param name="HRef" select="concat('../Pages/WebUpdate', $zj:ModuleXml, 'Page.zjx?Source=', $zj:Source,'&amp;ID=0&amp;RetURL=', $zj:SelfURL)"/>
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>
  <xsl:template match="@Module[.='List2' or .='ListDetail2']" mode="zj:Button">
    <table border="0">
      <tr>
        <td valign="top">
          <xsl:call-template name="zj:ExcelButton"/>
        </td>
      </tr>
    </table>
  </xsl:template>
  <xsl:template match="@Module" mode="zj:Button">
    <table border="0">
      <tr>
        <td valign="top">
          <xsl:call-template name="zj:ExcelButton"/>
          <xsl:if test="not($zj:XmlData/Toolkit/zj:DisablePage/Insert)">
            <xsl:call-template name="zj:HRefButton">
              <xsl:with-param name="Name" select="'新建'"/>              
              <xsl:with-param name="HRef">
                <xsl:choose>
                  <xsl:when test="contains( $zj:SelfURL,'AutoTable')">
                    <xsl:value-of select="concat('AutoTableInsertPage.zjx?Table=', $zj:Source, '&amp;', 'RetURL=', $zj:SelfURL)"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="concat('../Pages/WebInsert', $zj:ModuleXml, 'Page.zjx?Source=', $zj:Source,'&amp;RetURL=', $zj:SelfURL)"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:with-param>
            </xsl:call-template>
          </xsl:if>
        </td>
      </tr>
    </table>
  </xsl:template>
  <xsl:template name="zj:ExcelButton">
    <xsl:variable name="total" select="$zj:Toolkit/Page/TotalRows"/>
    <xsl:variable name="url" select="concat('../Pages/WebExcel', substring-after($zj:ListHeadUrl, 'WebList'), '&amp;No=true&amp;Rows=', $total, $zj:ListOrder)"/>
    <xsl:call-template name="zj:HRefClickButton">
      <xsl:with-param name="Name" select="'导出Excel'"/>
      <xsl:with-param name="HRef" select="$url"/>
      <xsl:with-param name="OnClick" select="concat('CheckRows(', $total, ')')"/>
      <xsl:with-param name="Target" select="'_top'"/>
    </xsl:call-template>
  </xsl:template>
</xsl:stylesheet>
